<template>
  <div class="detail-rate">
    <div class="rate-top">
      <span class="title">用户评价</span>
      <span class="more">更多</span>
    </div>
    <div class="rate-main">
      <div class="rate-main-item" v-for="(item, index) in rate" :key="index">
        <div class="use">
          <img :src="item.user.avatar" alt="" class="avatar">
          <span class="name">{{item.user.uname}}</span>
        </div>
        <div class="msg">{{item.content}}</div>
        <div class="about">
          <span class="date">{{getCreateDate(item.created)}}</span>
          <span class="type">{{item.style}}</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'DetailRate',
  props: {
    rate: {
      type: Array,
      default() {
        return []
      }
    }
  },
  computed: {
    getCreateDate() {
      return function(s) {
        let d = new Date(s * 1000);
        let yy = d.getFullYear();
        let mm = d.getMonth() + 1;
        mm = mm < 10 ? '0' + mm : mm;
        let dd = d.getDay();
        dd = dd < 10 ? '0' + dd : dd;
        return `${yy}-${mm}-${dd}`;
      }
    }
  }
}
</script>
<style scoped>
  .detail-rate {
    border-bottom: 5px solid #f2f5f8;
  }
  .rate-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 10px;
    padding: 20px 10px;
    border-bottom: 2px solid #eee;
  }
  .rate-main-item{
    padding: 20px 15px 40px;
  }
  .rate-main-item .use{
    display: flex;
    align-items: center;
  }
  .rate-main-item .use img{
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
  }
  .rate-main-item .msg{
    margin-top: 15px;
    color: #3a3a3a;
    line-height: 1.7;
  }
  .rate-main-item .about{
    margin-top: 15px;
    color: #aaa;
  }
  .rate-main-item .about .date{
    margin-right: 10px;
  }
</style>